home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_02_06 / 2n06071a < prev    next >
Text File  |  1991-03-14  |  4KB  |  123 lines

  1.  
  2. /******************************************************************
  3. *      PrintDlgProc - Print status window dialog window
  4. *
  5. *      Global:
  6. *             bUserAbort
  7. *             hDlgPrint
  8. *
  9. *      Copyright:
  10. *             Original code by William H. Roetzheim (619) 669-6970
  11. *             Copyright 1990 by William H. Roetzheim
  12. *             All rights reserved.
  13. **********************************************************************/
  14.  
  15. BOOL FAR PASCAL      PrintDlgProc (HWND hDlg, unsigned iMessage, WORD wParam, LONG lParam)
  16. {
  17.        switch (iMessage)
  18.        {
  19.               case WM_COMMAND:
  20.                      switch (wParam)
  21.                      {
  22.                            case IDD_CANCEL:
  23.                                   bUserAbort = TRUE;
  24.                                   EnableWindow (GetParent (hDlg), TRUE);
  25.                                   DestroyWindow (hDlg);
  26.                                   hDlgPrint = 0;
  27.                                   break;
  28.  
  29.                            default:
  30.                                   return FALSE;
  31.                      }
  32.                      break;
  33.  
  34.               default:
  35.                      return FALSE;
  36.        }
  37.        return TRUE;
  38. }
  39.  
  40.  
  41. /******************************************************************
  42. *      AbortDlgProc - Dialog procedure for abort print
  43. *
  44. *      Global:
  45. *             bUserAbort
  46. *             hDlgPrint
  47. *
  48. *      Copyright:
  49. *             Original code by William H. Roetzheim (619) 669-6970
  50. *             Copyright 1990 by William H. Roetzheim
  51. *             All rights reserved.
  52. **********************************************************************/
  53.  
  54. BOOL FAR PASCAL AbortDlgProc (HDC hPrinterDC, short nCode)
  55. {
  56.        MSG msg;
  57.  
  58.        while (!bUserAbort && PeekMessage (&msg, (HWND) (WORD) 
  59.               NULL, 0, 0, (WORD) PM_REMOVE))
  60.        {
  61.               if (!hDlgPrint || !IsDialogMessage (hDlgPrint, &msg))
  62.               {
  63.                      TranslateMessage (&msg);
  64.                      DispatchMessage (&msg);
  65.               }
  66.        }
  67.        return !bUserAbort;
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74. /******************************************************************
  75. *      PrintNetwork - Print entire network, one page at a time.
  76. *
  77. *      Parameters:
  78. *
  79. *      Global:
  80. *             hInstance
  81. *             spProject
  82. *             rBlock
  83. *
  84. *      Copyright:
  85. *             Original code by William H. Roetzheim (619) 669-6970
  86. *             Copyright 1990 by William H. Roetzheim
  87. *             All rights reserved.
  88. **********************************************************************/
  89.  
  90. void PrintNetwork (void)
  91. {
  92.        HDC           hPrnDC;
  93.        FARPROC     lpfnAbortDlgProc, lpfnPrintDlgProc;
  94.  
  95.        if (NULL == (hPrnDC = GetPrinterDC (hNetworkWnd)))
  96.        {
  97.               return;
  98.        }
  99.  
  100.        bUserAbort = FALSE;
  101.        lpfnPrintDlgProc = MakeProcInstance (PrintDlgProc, hInstance);
  102.        hDlgPrint = CreateDialog (hInstance, "PRINTDLGBOX", hNetworkWnd, lpfnPrintDlgProc);
  103.        lpfnAbortDlgProc = MakeProcInstance (AbortDlgProc, hInstance);
  104.        Escape (hPrnDC, SETABORTPROC, 0, (LPSTR) lpfnAbortDlgProc, (LPSTR) NULL);
  105.  
  106.        /* Output actual data */
  107.        Escape (hPrnDC, STARTDOC, 0, 0, NULL);
  108.  
  109.        for (first page; next page; < last page)
  110.        {
  111.               Print out page worth of data
  112.               Escape (hPrnDC, NEWFRAME, 0, 0, NULL);
  113.        }
  114.        Escape (hPrnDC, ENDDOC, 0, NULL, NULL);
  115.  
  116.        if (!bUserAbort)
  117.        {
  118.               EnableWindow (hNetworkWnd, TRUE);
  119.               DestroyWindow (hDlgPrint);
  120.        }
  121.        DeleteDC (hPrnDC);
  122. }
  123.